import { createRouter, createWebHistory } from 'vue-router'
import staticRouters from './static-routers'



const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: staticRouters,
})

export function resetRouter () {
  router.getRoutes().forEach((route) => {
    const { name } = route
    if (name && !staticRouters.map((r) => r.name).includes(name as string)) {
      if (router.hasRoute(name)) router.removeRoute(name)
    }
  })
}

export default router
